#include <unistd.h>
#include <stdlib.h>

#include <fcntl.h>
#include <sys/stat.h>
#include <stdio.h>

/*write----
int main()
{
    //int kk = write(1, "here is some data\n", 18);
    //printf("write %d byte\n",kk);
    //if( kk != 18)
    //    write(2, "A write error has occurred on file descriptor 1\n", 46);
    //exit(0);
    //
    if((write(1, "here is some data\n", 18)) != 18)
        write(2, "A write error has occurred on file descriptor 1\n", 46);
    exit(0);
}
*/

/*
read
int main()
{
    char buffer[128];
    int nread;

    nread = read(0, buffer, 128);
    if (nread == -1)
    {
        write(2, "A read error has occurred\n", 26);
    }

    if ((write(1,buffer,nread)) != nread)
    {
        write(2, "A write error has occurred\n",27);
    }

    exit(0);
}
*/

//#int main()
//#{
//#    char c;
//#    int in,out;
//#
//#    in = open("file.in",O_RDONLY);
//#    out = open("file.out",O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
//#    while(read(in,&c,1) == 1)
//#        write(out,&c,1);
//#    exit(0);
//#}


int main()
{
    char buf[1024];
    int cread;
    int in,out;

    in = open("file.in",O_RDONLY);
    out = open("file.out",O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
    while((cread = read(in,buf,sizeof(buf))) >0)
        write(out,buf,cread);
    exit(0);
}


